<?php

GaAPI_Autoloader::instance()->load('GaAPI_Objects_Common_Object');

class GaAPI_Objects_AdGroup extends GaAPI_Objects_Common_Object {

    public $id;
    public $campaignId;
    public $campaignName;
    public $name;
    protected $_status;
    public $bids;
    public $stats;


    public function  __construct() {
        GaAPI_Autoloader::instance()->load('GaAPI_Objects_AdGroup_Status');
        $this->_status = new GaAPI_Objects_AdGroup_Status();
    }

    public function  __set($name,  $value) {
        if ($name == 'status') {
            $this->_status->set($value);
        }
        return $this->$name = $value;
    }


    public function &__get($name) {
        if ($name == 'status') {
            return $this->_status;
        }
    }


    public function setBids($name) {
        $className = 'GaAPI_Objects_AdGroup_Bids_' . $name;
        GaAPI_Autoloader::instance()->load($className);
        $this->bids = new $className;
    }

    public function  __toString() {
        $xml = '';
        $xml .= '<campaignId>' . $this->campaignId . '</campaignId>';
        $xml .= '<name>' . $this->name . '</name>';
        $xml .= '<status>' . $this->status . '</status>';
        $xml .= '<bids xsi:type="' . $this->bids->type . '">' . $this->bids . '</bids>';
        return $xml;
    }
}